package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import org.springframework.stereotype.Service;

/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {


     /**
     * 分页查询
     *
     * @param info       查询条件
     * @param pageSearch 分页信息
     * @return
     */
     @Override
     public PageResult<${entity}DTO> listPage(${entity}DTO info, PageSearch pageSearch) {
        ${entity} ${entity?uncap_first} = ObjConvertUtil.convert(info, ${entity}.class);
        LambdaQueryWrapper<${entity}> wrapper = new LambdaQueryWrapper<>(${entity?uncap_first});
         Page<${entity}DTO> page = new Page<>(pageSearch.getPage(), pageSearch.getLimit(), pageSearch.isSearchCount());
         Page<${entity}> addressPage = baseMapper.selectPage(page, wrapper);
         return ObjConvertUtil.convert(addressPage, ${entity}DTO.class);
         }

    /**
    * 列表
    *
    * @param info 查询条件
    * @return
    */
    @Override
    public List<${entity}DTO> list(${entity}DTO info) {
     ${entity} ${entity?uncap_first} = ObjConvertUtil.convert(info, ${entity}.class);
      LambdaQueryWrapper<${entity}> wrapper = new LambdaQueryWrapper<>(${entity?uncap_first});
      return ObjConvertUtil.convert(baseMapper.selectList(wrapper), ${entity}DTO.class);
      }

      /**
      * 根据Id值查询
      *
      * @param id id
      * @return
      */
      @Override
      public ${entity}DTO detail(Long id) {
      return ObjConvertUtil.convert(baseMapper.selectById(id), ${entity}DTO.class);
      }

      /**
      * 修改或添加
      *
      * @param entity 实体对象
      * @return
      */
      @Override
      public void addOrUpdate(${entity}DTO entity) {
      ${entity} ${entity?uncap_first} = ObjConvertUtil.convert(entity, ${entity}.class);
      if (null == ${entity?uncap_first}) {
      return;
      }
      if (null == ${entity?uncap_first}.getId()) {
      int insert = baseMapper.insert(${entity?uncap_first});
      return;
      }
      int i = baseMapper.updateById(${entity?uncap_first});
      }

      /**
      * 删除对象
      *
      * @param id id
      */
      @Override
      public void delete(Long id) {

      }



}
</#if>
